import QtQuick
import QtQuick.Controls
import QtQuick.Dialogs
import QtQuick.Layouts
import Qt5Compat.GraphicalEffects
import QtCore

Rectangle {
    id: root
    Layout.fillWidth: true
    Layout.fillHeight: true
    radius: 10
    color: "white"
    border.color: "#e0e0e0"
    layer.enabled: true
    layer.effect: DropShadow {
        transparentBorder: true
        horizontalOffset: 2
        verticalOffset: 2
        radius: 8.0
        samples: 17
        color: "#20000000"
    }

    ColumnLayout {
        anchors {
            fill: parent
            margins: 20
        }
        spacing: 10

        Button {
            Layout.fillWidth: true
            Layout.preferredHeight: 40
            background: Rectangle {
                color: parent.pressed ? "#1976D2" : "#2196F3"
                radius: 5
            }
            contentItem: Text {
                text: qsTr("简单文件选择")
                color: "white"
                font.pixelSize: 16
                horizontalAlignment: Text.AlignHCenter
                verticalAlignment: Text.AlignVCenter
            }
            onClicked: fileDialog.open()
        }

        Item{
            Layout.fillHeight: true
        }

        Label {
            id: resultLabel
            Layout.fillWidth: true
            wrapMode: Text.WordWrap
            font.pixelSize: 14
            color: "#424242"
            text: qsTr("选择的文件：未选择")
        }
    }

    FileDialog {
        id: fileDialog
        title: qsTr("选择文件")
        currentFolder: StandardPaths.standardLocations(StandardPaths.DocumentsLocation)[0]
        onAccepted: resultLabel.text = qsTr("选择的文件：") + selectedFile
        onRejected: resultLabel.text = qsTr("选择的文件：已取消选择")
    }
} 
